/*
 *
 * Copyright (C) 1997 Jayakrishnan Nair jk@csr.uvic.ca
 * WWW: http://www.csc.uvic.ca/~jk
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

/**
  * A Fancy label class which can show a gif
  */



import java.awt.*;
import java.applet.*;
import java.net.*;


class FancyLabel extends Canvas
	{
	protected Panel panel;
	private Image image;
	private String text;
	private boolean mousePushed = false;
   private MediaTracker tracker;
    private int width;
    private int height;

	FancyLabel(Panel panel, Image image, int width, int height)
		{
		this.panel = panel;
		this.image = image;
		this.text = text;
		tracker = new MediaTracker(this);
		tracker.addImage(this.image,0);
		try {
		    tracker.waitForID(0);
		} catch(InterruptedException e){}
		setBackground(Color.lightGray);
	    this.width = width;
	    this.height = height;
		}

		public Dimension preferredSize() {
		    return new Dimension(width,height);
		}

	public void update(Graphics g)
		{
		paint(g);
		}

	public void paint(Graphics g)
		{
		Dimension dim = size();
		int xSiz = image.getWidth(this);
		int ySiz = image.getHeight(this);
		int xPos = (dim.width - xSiz) / 2;
		int yPos = (dim.height - ySiz) / 2;
		g.setColor(Color.lightGray);
		g.fillRect(xPos, yPos, xSiz + 2, ySiz + 2);
		g.setColor(Color.white);
		g.drawLine(0, 0, dim.width - 1, 0);
		g.drawLine(0, 0, 0, dim.height - 1);
		g.drawLine(1, 1, dim.width - 2, 1);
		g.drawLine(1, 1, 1, dim.height - 2);
		g.setColor(Color.black);
		g.drawLine(0, dim.height - 1, dim.width - 1, dim.height - 1);
		g.drawLine(dim.width - 1, dim.height - 1, dim.width - 1, 0);
		g.setColor(Color.gray);
		g.drawLine(1, dim.height - 2, dim.width - 2, dim.height - 2);
		g.drawLine(dim.width - 2, dim.height - 2, dim.width - 2, 1);
		g.clipRect(2, 2, dim.width - 4, dim.height - 4);
		g.drawImage(image, xPos, yPos, this);
		}
	}

